﻿
var divi;
var map;
var geocoder;

ds_loadGoogle(); //document.getElementById("gMap"));


function ds_getMap() {

    if (!GBrowserIsCompatible()) return;

    if (map == null) {
        divi = document.getElementById("gMap");
        map = new GMap2(divi);
    }

    if (geocoder == null)
        geocoder = new GClientGeocoder();
} //fm

function ds_loadGoogle() {
		ds_loadFromAdress('treviso,ITALY');
		return;
		ds_getMap();
		
		return;
    ////9.188126,45.463671,0 milano
    map.setCenter(new GLatLng(45.46367, 9.188126), 13);
    map.addControl(new GMapTypeControl());
    map.addControl(new GLargeMapControl());
    map.addControl(new GScaleControl()); // Zomming

}



function ds_vediDaIndirizzo() {

    var address = document.getElementById("TextAdress").value;
    ds_loadFromAdress(address);
}

function ds_loadFromAdress(indirizzo) {

    ds_getMap();
    geocoder.getLocations(indirizzo, ds_addToMap);

}

function ds_loadGoogle2() {

    ds_getMap();
    var lon = document.getElementById("TextLong").value;
    var lat = document.getElementById("TextLat").value;

    map.setCenter(new GLatLng(lat, lon), 13);
    map.addControl(new GMapTypeControl());
    map.addControl(new GLargeMapControl());
    map.addControl(new GScaleControl()); // Zomming

} //fm

function ds_addToMap(response) {


    place = response.Placemark[0];

    // Retrieve the latitude and longitude
    point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);

    // Center the map on this point
    map.setCenter(point, 13);

    // Create a marker
    marker = new GMarker(point);

    // Add the marker to map
    map.addOverlay(marker);

    // Add address information to marker
    marker.openInfoWindowHtml(place.address);
} //fm

//]]>